package ar.edu.itba.pod.legajo48062;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.List;

import ar.edu.itba.node.api.NodeStatistics;
import ar.edu.itba.node.api.StatisticReports;
import ar.edu.itba.pod.agent.market.AgentState;
import ar.edu.itba.pod.agent.runner.Agent;

public class DistributedStatisticReports extends UnicastRemoteObject implements StatisticReports {
	private static final long serialVersionUID = 1L;

	private DistributedSimulation node;
	
	public DistributedStatisticReports(DistributedSimulation node) throws RemoteException{
		super();
		this.node=node;
	}
	
	@Override
	public NodeStatistics getNodeStatistics() throws RemoteException {
		List<AgentState> agentStates = new ArrayList<AgentState>();
		
		for (Agent a : node.getAgentsRunning()){
			agentStates.add(a.state());
		}
		
		return new NodeStatistics(node.getAgentsRunning().size(), agentStates);
	}

}
